﻿<phone:PhoneApplicationPage 
    x:Class="Zombsquare.Pages.ARPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ARControls="clr-namespace:GART.Controls;assembly=GART"
    xmlns:maps="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True">

    <phone:PhoneApplicationPage.Resources>
        <!-- Used for authentication against Bing maps -->
        <maps:ApplicationIdCredentialsProvider x:Key="BingCredentials" ApplicationId="AsoYwOquow1D9inkw-YSN1iYJ7xPqmsKHvKPUZP_7B_swwwPTbdEDyoF_gibHtpT" />
        
        <DataTemplate x:Key="PlayerItem">
            <Border BorderBrush="Black" BorderThickness="4" CornerRadius="8" Background="{Binding Tipo, Converter={StaticResource ARLabelConverter}}" Width="320">
                <Grid Margin="4">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="0.5*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="0.33*"/>
                        <RowDefinition Height="0.33*"/>
                        <RowDefinition Height="16"/>
                    </Grid.RowDefinitions>
                    <Image Grid.RowSpan="3" Source="Resources/Zombie_Icon.png" Stretch="None" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,10,0"/>
                    <TextBlock x:Name="NameBlock" TextWrapping="NoWrap" Text="{Binding Content}" FontSize="32" VerticalAlignment="Center" Margin="0,0,4,0" d:LayoutOverrides="Width" Grid.Column="1" TextTrimming="WordEllipsis"/>
                    <TextBlock Text="{Binding GeoLocation, Converter={StaticResource DistanceConverter}}" />
                </Grid>
            </Border>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar>
            <shell:ApplicationBarIconButton x:Name="RotateButton" IconUri="/Resources/Icons/AR/appbar.rotate.png" IsEnabled="True" Text="rotate" Click="RotateButton_Click"/>
            <shell:ApplicationBarIconButton x:Name="HeadingButton" IconUri="/Resources/Icons/AR/appbar.heading.png" IsEnabled="True" Text="Heading" Click="HeadingButton_Click"/>
            <shell:ApplicationBarIconButton x:Name="MapButton" IconUri="/Resources/Icons/AR/appbar.map.png" IsEnabled="True" Text="map" Click="MapButton_Click"/>
            <shell:ApplicationBarIconButton x:Name="ThreeDButton" IconUri="/Resources/Icons/AR/appbar.3D.png" IsEnabled="True" Text="3D" Click="ThreeDButton_Click"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

    <Canvas x:Name="LayoutRoot">
        <ARControls:ARDisplay x:Name="ARDisplay" Height="640" Width="480">
            <ARControls:VideoPreview x:Name="VideoPreview" />
            <ARControls:OverheadMap x:Name="OverheadMap" CredentialsProvider="{StaticResource BingCredentials}" />
            <ARControls:WorldView x:Name="WorldView" ItemTemplate="{StaticResource PlayerItem}">                
            </ARControls:WorldView>
            <ARControls:HeadingIndicator x:Name="HeadingIndicator"/>                
        </ARControls:ARDisplay>
    </Canvas>
    
</phone:PhoneApplicationPage>
